﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
using System.Xml.Linq;

namespace BurnSystems.Gpx.Gui
{
    /// <summary>
    /// Interaction logic for Window1.xaml
    /// </summary>
    public partial class Window1 : Window
    {
        public Window1()
        {
            InitializeComponent();
        }

        private void LoadGPX_Click(object sender, RoutedEventArgs e)
        {
            var dlg = new Microsoft.Win32.OpenFileDialog();
            dlg.AddExtension = true;
            dlg.CheckFileExists = true;
            dlg.CheckPathExists = true;
            dlg.DefaultExt = "gpx";
            dlg.Filter = "GPX-Dateien (*.gpx)|*.gpx|Alle Dateien (*.*)|*.*";
            dlg.RestoreDirectory = true;

            if (dlg.ShowDialog(this) == true)
            {
                var xdocument = XDocument.Load(dlg.FileName);
                var gpxDocument = new GpxDocument();
                gpxDocument.LoadFromXDocument(xdocument);

                this.TrackShow.Tracksegment =
                    gpxDocument.Tracks[0].TrackSegments[0];
                this.TrackShow.ZoomIn();
            }
        }
    }
}
